import type { personInfo, bindPhone, removeSort, queryType, actionInfp } from "./type.ts";
import request from "@/utils/request.ts";

// 个人信息
export const personInfoFn = function () {
    return request("/spray/mini/v1/account/my", "GET");
};
// 修改昵称/头像
export const editInfo = function (data: personInfo) {
    return request("/spray/mini/v1/account/my", "POST", data);
};
// 获取验证码
export const sendSms = function (data: string) {
    return request(`/spray/mini/v1/phone/sms/send`, "POST", data);
};
// 手动绑定手机号
export const bindPhoneFn = function (data: bindPhone) {
    return request(`/spray/mini/v1/phone/binding`, "POST", data);
};
// 一键绑定手机号
export const authPhone = function (data: any) {
    return request(`/spray/mini/v1/phone/auth`, 'PUT', data)
}
// 共享设别列表
export const deviceList = function (data: any) {
    return request('/spray/mini/v1/share/equipments', 'GET', data)
}
// 移动分组
export const removeSortFn = function (data: removeSort) {
    return request(`/spray/mini/v1/equipments/${data.equipmentId}/grouping/${data.groupId}`, 'POST', data)
}
// 设备共享成员列表
export const shareListFn = function (data: queryType) {
    return request(`/spray/mini/v1/share/equipment/${data.equipmentId}/accounts`, 'get', data)
}
// 编辑设备名称
export const editDeviceName = function (query:string,data: any) {
    return request(`/spray/mini/v1/share/equipment/${query}`,'post',data)
}
// 共享--移交绑定人
export const transferFn = function (data: actionInfp) {
    return request(`/spray/mini/v1/share/${data.shareId}/equipment/bind`, 'PUT', data)
}
// 共享-删除绑定
export const DeltransferFn = function (data: actionInfp) {
    return request(`/spray/mini/v1/share/${data.shareId}/equipment/unbind/${data.accountId}`, 'post', data)
}
// 工作日志列表
export const workRecords = function (data: queryType) {
    return request('/spray/mini/v1/account/equipment/work/records', 'GET', data)
}
// 操作日志列表
export const operationRecords = function (data: queryType) {
    return request('/spray/mini/v1/account/equipment/operates', 'GET', data)
}
// 警告列表
export const warnRecords = function (data: queryType) {
    return request('/spray/mini/v1/account/equipment/warnings', 'GET', data)
}
// 处理告警
export const handlewarn = function (data: string) {
    return request(`/spray/mini/v1/equipment/${data}/fix`,'POST')
}
// 保养记录
export const maintenanceFn = function (data: queryType) {
    return request(`/spray/mini/v1/account/equipment/maintenance/records`, 'GET', data)
}
// 帮助列表
export const helpsList = function () {
    return request('/spray/mini/v1/account/helps', 'GET')
}
// 帮助详情
export const helpsInfo = function (data:number) {
    return request(`/spray/mini/v1/account/help/${data}`, 'GET')
}
// 反馈意见
export const saveFeedback = function (data: any) {
    return request(`/spray/mini/v1/account/feedback`, 'POST', data)
}

// 删除分组
export const deleteGroupFn = function (groupId:number) {
    return request(`/spray/mini/v1/equipment/group/${groupId}`,'DELETE')
}
// 添加编辑分组
export const addeditGroupFn = function (groupId:number,data:any) {
    return request(`/spray/mini/v1/equipment/group/${groupId}`, 'POST', data)
}